<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

require_once(dirname(__FILE__).'/../lib/BasesfGuardAuthComponents.class.php');
require_once(sfConfig::get('sf_lib_dir').'/vendor/EpiFramework/EpiCurl.php');
require_once(sfConfig::get('sf_lib_dir').'/vendor/EpiFramework/EpiOAuth.php');
require_once(sfConfig::get('sf_lib_dir').'/vendor/EpiFramework/EpiTwitter.php');

/**
 *
 * @package    symfony
 * @subpackage plugin
 * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
 * @version    SVN: $Id: components.class.php 23319 2009-10-25 12:22:23Z Kris.Wallsmith $
 */
class sfGuardAuthComponents extends BasesfGuardAuthComponents
{
    public function executeSignin_form_min() {
        parent::executeSignin_form();
    }
    
    public function executeSocialSignin() {
        $this->twitter = new EpiTwitter(sfConfig::get('app_twitter_consumer_key'), sfConfig::get('app_twitter_consumer_secret'));
        
        $fbconfig['appid' ]     = sfConfig::get('app_facebook_appid');
        $fbconfig['secret']     = sfConfig::get('app_facebook_secret');
        $fbconfig['baseurl']    = sfContext::getInstance()->getRouting()->generate('apply_facebook', array(), true);
        
        try {
            include_once sfConfig::get('sf_lib_dir').'/vendor/PHP-SDK-3.0-Graph-API-Facebook/facebook.php';
        } catch(Exception $o) {
            error_log($o);
        }
        // Create our Application instance.
        $facebook = new Facebook(array(
            'appId'  => $fbconfig['appid'],
            'secret' => $fbconfig['secret'],
            'cookie' => true,
        ));

        $this->fb_login_url = $facebook->getLoginUrl(
            array(
                'scope' => 'email,offline_access,publish_stream,user_birthday,user_location,user_work_history,user_about_me,user_hometown',
                'redirect_uri' => $fbconfig['baseurl']
            ));
    }
}